package com.Merlin.myapplication.kotlin

fun main() {
    val car = Car("小轿车")
    car.show()

    val car2 = Car("自行车")
    car2.show()

    val car3 = Car("自定义车辆-A", 100)
    car3.show()
}

class Car(var name: String) {
    var wheels = 0

    init {
        wheels = when (name) {
            "自行车" -> 2
            "小轿车" -> 4
            "大货车" -> 12
            else -> 4
        }
    }

    constructor(name: String, wheels: Int) : this(name) {
        this.wheels = wheels
    }

    fun show() {
        println("车辆名称: $name, 车轮数量: $wheels")
    }

}